/**
 * Licensed under the Apache License Version 2.0.
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package net.interknit.knitter.cg.view;

import net.interknit.knitter.cg.model.JavaType;

/**
 *
 */
public class JavaTypeViewFactory
{
	public static JavaTypeView create(JavaType javaType)
	{
		if(javaType.getInspector().isAnyType())
		{
			return new AnyTypeView(javaType);
		}
		else if(javaType.getInspector().isPrimitiveType())
		{
			return new PrimitiveTypeView(javaType);
		}
		else if(javaType.getInspector().isBasicType())
		{
			return new BasicTypeView(javaType);
		}
		else if(javaType.getInspector().isBigIntegerType())
		{
			return new BigIntTypeView(javaType);
		}
		else if(javaType.getInspector().isBigDecimalType())
		{
			return new BigDoubleTypeView(javaType);
		}
		else if(javaType.getInspector().isFileType())
		{
			return new FileTypeView(javaType);
		}
		else if(javaType.getInspector().isInputStreamType())
		{
			return new InputStreamTypeView(javaType);
		}
		else if(javaType.getInspector().isReaderType())
		{
			return new ReaderTypeView(javaType);
		}
		else if(javaType.getInspector().isDateTimeType())
		{
			return new DateTimeTypeView(javaType);
		}
		else if(javaType.getInspector().isEnumType())
		{
			return new EnumTypeView(javaType);
		}
		else if(javaType.getInspector().isArrayType())
		{
			return new ArrayTypeView(javaType);
		}
		else if(javaType.getInspector().isCollectionType())
		{
			if(AnyCollectionTypeView.isAnyCollectionTypeView(javaType))
			{
				return new AnyCollectionTypeView(javaType);
			}
			else
			{
				return new CollectionTypeView(javaType);
			}
		}
		else if(javaType.getInspector().isMapType())
		{
			if(AnyMapTypeView.isAnyMapTypeView(javaType))
			{
				return new AnyMapTypeView(javaType);
			}
			else
			{
				return new MapTypeView(javaType);
			}
		}
		else if(javaType.isSeedType())
		{
			return new SeedTypeView(javaType);
		}
		else if(javaType.getInspector().isCustomType())
		{
			return new CustomTypeView(javaType);
		}
		else if(javaType.getInspector().isJavaTypeIgnored())
		{
			return new IgnoredTypeView(javaType);
		}
		else
		{
			throw new RuntimeException("JavaType represents an unknown type: " + javaType.getJavaTypeId());
		}
	}
}
